package compile;

/**
 * @author SongJun
 * @description TODO:
 * @date 2021/9/28 16:34
 */
public abstract class AstVisitor {
    Object visitProg(Prog prog){
        Object retVal = null;
        for(Statement x : prog.getStmts()){
            if(x instanceof FunctionDecl){
                retVal = this.visitFunctionDecl((FunctionDecl)x);
            } else {
                retVal = this.visitFunctionCall((FunctionCall)x);
            }
        }
        return retVal;
    }

    Object visitFunctionDecl(FunctionDecl functionDecl){
        return this.visitFunctionBody(functionDecl.getBody());
    }

    Object visitFunctionBody(FunctionBody functionBody){
        Object retVal = null;
        for(Statement x : functionBody.stmts){
            if(x instanceof FunctionCall){
                retVal = this.visitFunctionCall((FunctionCall)x);
            }
        }
        return retVal;
    }

    Object visitFunctionCall(FunctionCall functionCall){
        return null;
    }
}
